// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   Pagination.java

package com.iphaeton.common.helper;


public class Pagination
{

    public Pagination(int totalPage, int itemCount, int pageSize)
    {
        this.pageSize = 10;
        row = "";
        state = 0;
        if(totalPage > 0)
            setTotalPage(totalPage);
        if(itemCount > 0)
            setItemCount(itemCount);
        if(pageSize > 0)
            setPageSize(pageSize);
    }

    public int getTotalPage()
    {
        return totalPage;
    }

    public void setTotalPage(int totalPage)
    {
        this.totalPage = totalPage;
    }

    public int getItemCount()
    {
        return itemCount;
    }

    public void setItemCount(int resultCount)
    {
        itemCount = resultCount;
    }

    public int getPage()
    {
        return page;
    }

    public void setPage(int page)
    {
        if(page > totalPage)
            this.page = totalPage;
        else
        if(page <= 0)
            this.page = 1;
        else
            this.page = page;
    }

    public int getState()
    {
        return state;
    }

    public void setState(int state)
    {
        this.state = state;
    }

    public String getRow()
    {
        return row;
    }

    public void setRow(String row)
    {
        this.row = row;
    }

    public boolean getHasPrevious()
    {
        return page > 1;
    }

    public int getPreviousPage()
    {
        if(page - 1 <= 0)
            return 1;
        else
            return page - 1;
    }

    public boolean getHasNext()
    {
        return totalPage > page;
    }

    public int getNextPage()
    {
        if(page + 1 >= totalPage)
            return totalPage;
        else
            return page + 1;
    }

    public int getPageSize()
    {
        return pageSize;
    }

    public void setPageSize(int pageSize)
    {
        this.pageSize = pageSize;
    }

    public String getHqlQueryString()
    {
        return hqlQueryString;
    }

    public void setHqlQueryString(String hqlQueryString)
    {
        this.hqlQueryString = hqlQueryString;
    }

    public int getStartItemPos()
    {
        int temp = (page - 1) * pageSize;
        return temp;
    }

    public int getMaxItemNum()
    {
        int maxItemNum = 0;
        if(itemCount <= pageSize)
            maxItemNum = itemCount;
        else
        if(itemCount - (page - 1) * pageSize >= pageSize)
            maxItemNum = pageSize;
        else
            maxItemNum = itemCount - (page - 1) * pageSize;
        return maxItemNum;
    }

    public int getCurrentPageBeginPos()
    {
        return previousPage * pageSize + 1;
    }

    public int getCurrentPageEndPos()
    {
        return page * pageSize;
    }

    private int totalPage;
    private int itemCount;
    private int page;
    private boolean hasPrevious;
    private int previousPage;
    private boolean hasNext;
    private int nextPage;
    private String hqlQueryString;
    private int pageSize;
    private String row;
    private int state;
}
